#include <Arduino.h>
#include <DigitalTube.h>

int digitalRead(uint32_t ulPin) {
    PinName pn = digitalPinToPinName(ulPin);
    GPIO_TypeDef *GPIOx = get_GPIO_Port(STM_PORT(pn));
    uint32_t PinMask = STM_LL_GPIO_PIN(pn);
    uint32_t GPIO_Pin = (PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU;    
    return (HAL_GPIO_ReadPin(GPIOx, GPIO_Pin) == GPIO_PIN_RESET) ? LOW : HIGH;
}

const uint8_t digital_tube_pos_pins[8] = {PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8};
const uint8_t digital_tube_neg_pins[3] = {PA13, PA14, PA15};

uint32_t press_times = 0;

DigitalTube digital_tube(digital_tube_pos_pins, digital_tube_neg_pins);

#define F_BUTTON_PIN PB1
#define R_BUTTON_PIN PB2
#define F_R_BUTTON_PIN PB3

void setup_digital_tube();
void loop_digital_tube();

void setup_button();

